import Vue from 'vue'
import router from "../router";
Vue.directive('permission',{
    // inserted 当指令挂载到dom节点上触发
    inserted(el,binding){
        let action=binding.value.action
        let effect = binding.value.effect
        // 判断当前路由meta信息中是否具备action的权限
        if (router.currentRoute.meta.indexOf(action)==-1){
            if (effect==='disabled'){
                el.disabled=true
                el.classList.add('is-disabled')
            }else {
                el.parentNode.removeChild(el)
            }
        }
    }
})